home *** CD-ROM | disk | FTP | other *** search
/ The Fatted Calf / The Fatted Calf.iso / Applications / Scheduling / Cassandra / Source / Event.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-11-01  |  6.5 KB  |  216 lines

  1. //
  2. // Event.h
  3. // Copyright (c) 1989, 1990 by Jiro Nakamura 
  4. // All rights reserved
  5. //
  6. // Interface definition of class Event. Event handles the database management
  7. // of Cassandra.
  8. // Event is due for total rewriting.
  9. //
  10. // RCS Information
  11. // Revision Number->    $Revision: 1.11 $
  12. // Last Revised->        $Date: 91/11/01 17:23:52 $
  13. //
  14.  
  15. #import <objc/Object.h>
  16. #import <time.h>
  17. #import "cass.h"    
  18.  
  19. struct tm *fixAnniversary( struct tm *time, int mode, int sub);
  20. @interface Event : Object
  21. {
  22.     char eventFile[128];    // The pathname of the event database
  23.  
  24.     EFileLink    present, previous, next;    // links to 
  25.                 //previous and next records and itself 
  26.                 // See documentation for queue implementation
  27.                 // details
  28.     int    eventType;    // Event type
  29.                 //  0  = normal event (appointment)
  30.                 //  1  = reminder (day things)
  31.                                  
  32.     struct tm ts;        // time structure  see ctime(3) for details 
  33.     int    priority,    // Priority of message (when it gets viewed) 
  34.         destroy,    // Destroy after message?     0= never destroy
  35.                 //  1 = destroy immediately after, 
  36.                 //   2...n = destroy after n calls 
  37.         snoozeNo,    // No of snooze times
  38.         snoozeInt,    // The snooze intervals themselves (in minutes) 
  39.         duration,    // Duration of event (for scheduling)
  40.         version;    // What version Event file is this?
  41.                 // 0,blank    - v1.4 or below
  42.                 // 1          v1.5 (includes duration)
  43.                             
  44.     int    anniversary;    // Anniversary event, 
  45.                 // 0 = no anniversary 
  46.                 // (int) (anniversary / 100) is the "base
  47.                 // interval": 
  48.                 //  1 = daily      
  49.                 //  2 = weekly
  50.                 //  3 = monthly
  51.                 //  4 = yearly
  52.                 //  5 = special weekly - see "Annv Special Field" for
  53.                 //    days. Base interval is a binary flag field
  54.                 //    for which week it is in:  Bit 0: First week
  55.                 //                  Bit 4: Fifth week
  56.                 // anniversary % 100 is the number of 
  57.                 // "base interval" that
  58.                 // make up the "true interval" 
  59.                 // between anniversary events
  60.     
  61.     int    annvSpecial;    // Anniversary special field
  62.                 // For Special weekly it holds the days in a binary
  63.                 // flag field:
  64.                 //     Bit 0:    Sunday
  65.                 //     Bit 7: Saturday
  66.     
  67.     enum Actions {nothing, playSound, playAndDeleteSound, runCommand,
  68.             mailPerson}    alarmAction;
  69.                     
  70.     BOOL showMessage;    // Whether to show the alarmPanel or not
  71.  
  72.     char alarmSound[128];    /* The alarm sound name */
  73.     char msg[MESSAGE_SIZE];    /* message buffer */
  74.  
  75.     id global;        // Set by IB. Accessor to Global class
  76. }
  77. // Constructor:        newAt: (const char *) eFile;
  78. // Description:        Constructs new object instance of Event, with the Event
  79. //                reading the file <eFile>
  80. +newAt: (const char *) eFile;
  81.  
  82. /* low level routines  dealing with event links themselves */ 
  83.  
  84. // Method:        readEvent : (EFileLink) here
  85. // Arguments:        (EFileLink) here  -> the EFileLink to read from
  86. // Description:        Reads the event directly from the queue with <here> 
  87. //            as the index.
  88. // Return Value:    <self>
  89. - readEvent : (EFileLink) here;    
  90.  
  91.  
  92. // Method:        writeEvent : (EFileLink) here
  93. // Arguments:        (EFileLink) here  -> the EFileLink to write to
  94. // Description:        Writes the event directly into the queue 
  95. //            with <here> as the index. Note that this is not an 
  96. //            insert, so the next and previous pointers from the 
  97. //            last read from this event should be preserved
  98. //            or new pointers should be made and changed 
  99. //            appropriately.
  100. // Return Value:    <self>
  101. - writeEvent : (EFileLink) here;     /* write itself into the event file */
  102.  
  103.  
  104.  
  105. /* Higher level methods that deal somewhat abstractly with the queue */        
  106.  
  107. // Method:        firstEvent
  108. // Arguments:        None.
  109. // Description:        reads the first event. Equivalent to:
  110. //                [ev readEvent:0];
  111. //                [ev readEvent:  [ev next]];
  112. // Return Value:    returns with the first event read into its internals
  113. - firstEvent;            
  114.  
  115.  
  116. // Method:        (EFileLink) insertEvent
  117. // Arguments:        None, event to be inserted must be already in object
  118. // Description:        Inserts itself into the queue. It is intelligent
  119. //            enough to convert all mistaken dates and times into the
  120. //            proper format before inserting itself, so that other
  121. //            modules that use it can simply add blindly to dates.
  122. //            insertEvent is equivalent to insertEventFrom: 1
  123. // Return Value:    The particular EFileLink that it inserted itself into.
  124. - (EFileLink) insertEvent;    
  125.  
  126.  
  127. // Method:        (EFileLink) insertEventFrom: (EFileLink) here
  128. // Arguments:        (EFileLink) here   -> start inserting from <here>
  129. // Description:        Same as insertEvent except that the search
  130. //            for empty events starts from <here>, so that
  131. //            if you KNOW where an deleted EFileLink is, 
  132. //            then you can use this method to speed things up
  133. //             somewhat.
  134. // ReturnValue:        The EFileLink that it inserted itself into.
  135. - (EFileLink) insertEventFrom: (EFileLink) here;
  136.  
  137.  
  138. // Method:        deleteEvent: (EFileLink) here
  139. // Arguments:        (EFileLink) here   -> the event to delete
  140. // Description:        Delete the event <here>
  141. // Return Value:    <self>
  142. - deleteEvent : (EFileLink) here;    
  143.  
  144.  
  145. // Method:        int murderEvent : (EFileLink) here
  146. // Arguments:        (EFileLink) here   -> the event to "murder"
  147. // Description:        "Murdering" an event deletes an event, but 
  148. //            if it is an anniversary
  149. //            event, then it reinstalls it appropriately
  150. //            in the future. See above for description
  151. //            of state variables for "anniversary" events.
  152. // Return Value:    The EFileLink where the new event lies.  
  153. //            -1 if it was not reinserted
  154. - (int) murderEvent : (EFileLink) here;    
  155.  
  156. /*  Accessors */
  157. /* See heading above for description of these variables */
  158. - (EFileLink) present;    
  159. - (EFileLink) previous;
  160. - (EFileLink) next;
  161. - (int) destroy;
  162. - (int) priority;
  163. - (int) anniversary;
  164. - (int) annvSpecial;
  165. - (int) snoozeNo;
  166. - (int) snoozeInt;
  167. - (BOOL) playAlarm;
  168. - (BOOL) showMessage;
  169. - (BOOL) deleteSound;
  170. - (BOOL) mailPerson;
  171. - (BOOL) runCommand;
  172.  
  173. - (int) alarmAction;
  174.  
  175. - (char *) alarmSound;
  176. - (char *) message;
  177. - (struct tm *) time;
  178. - (int) mday;        // These access the time structure directly, instead of
  179. - (int) mon;        // using the structure accessors
  180. - (int) year;
  181. - (int) hour;
  182. - (int) min;
  183. - (int) sec;
  184. - (int) wday;
  185. - (int) yday;
  186.  
  187. - setPresent : (EFileLink) apresent;
  188. - setPrevious : (EFileLink) aprevious;
  189. - setNext : (EFileLink) anext;
  190. - setDestroy : (int) dst;
  191. - setPriority : (int) si;
  192. - setAnniversary : (int) anv;
  193. - setAnnvSpecial: (int) anvS;
  194. - setSnoozeNo : (int) sn;
  195. - setSnoozeInt: (int) si;
  196. - setPlayAlarm: (BOOL) aFlag;
  197. - setShowMessage: (BOOL) aFlag;
  198. - setDeleteSound:(BOOL) aFlag;
  199. - setMailPerson:(BOOL) aFlag;
  200. - setAlarmSound: (char *) alarmSound;
  201. - setMessage: (char *) message;
  202. - setRunCommand: (BOOL) aFlag;
  203. - setTime : (struct tm *) time;
  204. - setAlarmAction: (int) aa;
  205. - setMday : (int) x;
  206. - setMon: (int) x;
  207. - setYear: (int) x;
  208. - setHour: (int) x;
  209. - setMin: (int) x;
  210. - setSec: (int) x;
  211. - setWday: (int) x;
  212. - setYday:(int) x;
  213. @end
  214.  
  215.  
  216.